package com.hae.cloud.testswagger.api;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping
@Api //声明这是需要对外暴露的接口，便于Swagger寻找
public class SwaggerController {

    /**
     * 不推荐使用RequestMapping，否则swager会对GET，POST，DELETE等请求各生成一份，但都用不到
     * @return
     */
    @ApiOperation("swagger演示接口")
    @GetMapping("/test")
    public String apiTest() {
        System.out.println("swagger演示接口");
        return "swagger演示接口";
    }

    @ApiOperation("swagger演示接口")
    @ApiImplicitParam(name = "userName", value = "用户名", required = true, dataType = "String" ) //注释参数信息
    @GetMapping("/getUser")
    public String getUser(@RequestParam("userName") String userName) {
        System.out.println("userName");
        return userName;
    }
}

